//
//  UIAlertController+extension.swift
//  iUtil
//
//  Created by wendachuan on 19/3/22.
//  Copyright © 2019年 wendachuan. All rights reserved.
//

import Foundation
import UIKit

public extension UIAlertController {

    /// 显示消息对话框
    ///
    /// - parameter title: 标题
    /// - parameter message: 消息内容
    /// - parameter handler: 对话框关闭事件回调
    static func showMessageDialog(_ title: String? = nil, message: String? = nil, handler: ((UIAlertAction) -> Void)? = nil) {
        let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
        alert.addAction(UIAlertAction(title: "确定", style: UIAlertAction.Style.default, handler: handler))
        UIApplication.shared.keyWindow!.rootViewController!.present(alert, animated: true, completion: nil)
    }
}
